<!DOCTYPE html>
<html>
<head>
    <title>SRS</title>   
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
    <style>
        body{
            padding-top: 55px;
        }
        #my_modal_footer {
            margin-top: -20px;
            padding-top: 3px;
        }
        .div_play_time {
            margin-top: 10px;
        }
        #pb_buffer_bg {
            margin-top: -4px;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <a id="srs_index" class="brand" href="#">SRS</a>
            <div class="nav-collapse collapse">
                <ul class="nav">
                    <li class="active"><a id="nav_srs_player" href="srs_player.html">SRS播放器</a></li>
                    <li><a id="nav_srs_publisher" href="srs_publisher.html">SRS编码器</a></li>
                    <li><a id="nav_srs_chat" href="srs_chat.html">SRS会议</a></li>
                    <li><a id="nav_srs_bwt" href="srs_bwt.html">SRS测网速</a></li>
                    <li><a id="nav_jwplayer6" href="jwplayer6.html">JWPlayer6播放器</a></li>
                    <li><a id="nav_osmf" href="osmf.html">AdobeOSMF播放器</a></li>
                    <li><a id="nav_vlc" href="vlc.html">VLC播放器</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <div class="alert alert-info fade in">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong><span>Usage:</span></strong> <span>输入RTMP/HTTP地址后点击“播放视频”即可播放视频</span>
    </div>
    <div class="form-inline">
        URL:
        <input type="text" id="txt_url" class="input-xxlarge" value="">
        <button class="btn btn-primary" id="btn_play">播放视频</button>
        <button class="btn" id="btn_generate_link">生成链接</button>
    </div>
    <div id="link_modal" class="modal hide fade">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3><a href="https://github.com/ossrs/srs">SRS Link Generator</a></h3>
        </div>
        <div class="modal-body">
            <div class="form-horizontal">
                <div class="control-group">
                    <label class="control-label" for="link_server">服务器地址</label>
                    <div class="controls">
                        <span id="link_server" class="span4 uneditable-input"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="link_port">服务器端口</label>
                    <div class="controls">
                        <span id="link_port" class="span2 uneditable-input"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="link_vhost">RTMP Vhost</label>
                    <div class="controls">
                        <span id="link_vhost" class="span4 uneditable-input"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="link_app">RTMP App</label>
                    <div class="controls">
                        <span id="link_app" class="span4 uneditable-input"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="link_stream">RTMP Stream</label>
                    <div class="controls">
                        <span id="link_stream" class="span4 uneditable-input"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="link_rtmp">RTMP地址</label>
                    <div class="controls">
                        <span id="link_rtmp" class="span4 uneditable-input"></span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="link_url">播放链接地址</label>
                    <div class="controls">
                        <div style="margin-top:5px;"><a href="#" id="link_url" target="_blank">请右键拷贝此链接地址.</a></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal-footer"></div>
    </div>
    <div class="container">
        <hr/>
        <span>
            注意：必须按照<a href="https://github.com/ossrs/srs/wiki/SampleDemo">SRS DEMO</a>
            启动和设置服务器，下面所有的链接才能观看。
        </span>
        <div class="accordion" id="main_accordion">
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse1">
                        <strong>[1] SRS示例播放流: 原始流</strong>
                    </span>
                </div>
                <div id="collapse1" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish">rtmp://demo.srs.com/live/livestream</a> <br/>
                        <span>用户推送过来的唯一一路流，经过服务器的多种变换和再转发。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse10">
                        <strong>[2] SRS示例播放流: 原始流HLS</strong>
                    </span>
                </div>
                <div id="collapse10" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_hls" target="_blank">http://demo.srs.com/live/livestream.m3u8</a> <br/>
                        <span>对用户的流进行HLS切片（若编码为非H264/AAC，HLS流会自动禁用）。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse2">
                        <strong>[3] SRS示例播放流: 转码配置LD流</strong>
                    </span>
                </div>
                <div id="collapse2" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_ld">rtmp://demo.srs.com/live/livestream_ld</a> <br/>
                        <span>对原始流加了<a href="http://ffmpeg.org/ffmpeg-filters.html#overlay">FFMPEG图片水印</a></span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse11">
                        <strong>[4] SRS示例播放流: 转码配置LD流HLS</strong>
                    </span>
                </div>
                <div id="collapse11" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_ld_hls" target="_blank">http://demo.srs.com/live/livestream_ld.m3u8</a> <br/>
                        <span>对转码配置LD流进行HLS切片。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse3">
                        <strong>[5] SRS示例播放流: 转码配置SD流</strong>
                    </span>
                </div>
                <div id="collapse3" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_sd">rtmp://demo.srs.com/live/livestream_sd</a> <br/>
                        <span>对原始流应用了<a href="http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction">FFMPEG翻转滤镜</a></span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse12">
                        <strong>[6] SRS示例播放流: 转码配置SD流HLS</strong>
                    </span>
                </div>
                <div id="collapse12" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_sd_hls" target="_blank">http://demo.srs.com/live/livestream_sd.m3u8</a> <br/>
                        <span>对转码配置SD流进行HLS切片。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse4">
                        <strong>[7] SRS示例播放流: 转发原始流</strong>
                    </span>
                </div>
                <div id="collapse4" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_fw">rtmp://demo.srs.com:19350/live/livestream</a> <br/>
                        <span>将用户推送的流转发到另外的vhost或服务器，做热备用。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse13">
                        <strong>[8] SRS示例播放流: 转发原始流HLS</strong>
                    </span>
                </div>
                <div id="collapse13" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_fw_hls" target="_blank">http://demo.srs.com/forward/live/livestream.m3u8</a> <br/>
                        <span>对转发原始流进行HLS切片（若编码为非H264/AAC，HLS流会自动禁用）。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse5">
                        <strong>[9] SRS示例播放流: 转发转码配置LD流</strong>
                    </span>
                </div>
                <div id="collapse5" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_fw_ld">rtmp://demo.srs.com:19350/live/livestream_ld</a> <br/>
                        <span>FFMPEG加水印后的流也会自动转发。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse14">
                        <strong>[10] SRS示例播放流: 转发转码配置LD流HLS</strong>
                    </span>
                </div>
                <div id="collapse14" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_fw_ld_hls" target="_blank">http://demo.srs.com/forward/live/livestream_ld.m3u8</a> <br/>
                        <span>对转发转码配置LD流进行HLS切片，所有转发的流会自动支持HLS。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse6">
                        <strong>[11] SRS示例播放流: 转发转码配置SD流</strong>
                    </span>
                </div>
                <div id="collapse6" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_fw_sd">rtmp://demo.srs.com:19350/live/livestream_sd</a> <br/>
                        <span>FFMPEG翻转后的流也会自动转发。</span>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <span class="accordion-toggle" data-toggle="collapse" data-parent="#main_accordion" href="#collapse15">
                        <strong>[12] SRS示例播放流: 转发转码配置SD流HLS</strong>
                    </span>
                </div>
                <div id="collapse15" class="accordion-body collapse">
                    <div class="accordion-inner">
                        <a href="#" id="srs_publish_fw_sd_hls" target="_blank">http://demo.srs.com/forward/live/livestream_sd.m3u8</a> <br/>
                        <span>对转发转码配置SD流进行HLS切片，所有转发的流会自动支持HLS。</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="main_modal" class="modal hide fade">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3><a href="https://github.com/ossrs/srs">SrsPlayer</a></h3>
        </div>
        <div class="modal-body">
            <div id="player"></div>
            <div class="progress progress-striped active" id="pb_buffer_bg">
                <div class="bar" style="width: 0%;" id="pb_buffer"></div>
            </div>
        </div>
        <div class="modal-footer" id="my_modal_footer">
            <div>
                <div class="btn-group dropup">
                    <button class="btn dropdown-toggle" data-toggle="dropdown">
                        设置全屏比例大小<span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a id="btn_fs_size_screen_100" href="#">屏幕大小(100%)</a></li>
                        <li><a id="btn_fs_size_screen_75" href="#">屏幕大小(75%)</a></li>
                        <li><a id="btn_fs_size_screen_50" href="#">屏幕大小(50%)</a></li>
                        <li><a id="btn_fs_size_video_100" href="#">视频大小(100%)</a></li>
                        <li><a id="btn_fs_size_video_75" href="#">视频大小(75%)</a></li>
                        <li><a id="btn_fs_size_video_50" href="#">视频大小(50%)</a></li>
                    </ul>
                </div>
                <div class="btn-group dropup">
                    <button class="btn dropdown-toggle" data-toggle="dropdown">设置显示比例<span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li><a id="btn_dar_original" href="#">视频原始比例</a></li>
                        <li><a id="btn_dar_21_9" href="#">宽屏影院(21:9)</a></li>
                        <li><a id="btn_dar_16_9" href="#">宽屏电视(16:9)</a></li>
                        <li><a id="btn_dar_4_3" href="#">窄屏(4:3)</a></li>
                        <li><a id="btn_dar_fill" href="#">填充(容器比例)</a></li>
                    </ul>
                </div>
                <div class="btn-group dropup">
                    <button class="btn dropdown-toggle" data-toggle="dropdown">设置缓冲区大小<span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li><a id="btn_bt_0_1" href="#">0.1秒(实时)</a></li>
                        <li><a id="btn_bt_0_2" href="#">0.2秒(实时)</a></li>
                        <li><a id="btn_bt_0_3" href="#">0.3秒(实时)</a></li>
                        <li><a id="btn_bt_0_5" href="#">0.5秒(实时)</a></li>
                        <li><a id="btn_bt_0_8" href="#">0.8秒(会议)</a></li>
                        <li><a id="btn_bt_1_0" href="#">1秒(低延迟)</a></li>
                        <li><a id="btn_bt_2_0" href="#">2秒(较低延时)</a></li>
                        <li><a id="btn_bt_3_0" href="#">3秒(流畅播放)</a></li>
                        <li><a id="btn_bt_4_0" href="#">4秒(流畅播放)</a></li>
                        <li><a id="btn_bt_5_0" href="#">5秒(网速较低)</a></li>
                        <li><a id="btn_bt_6_0" href="#">6秒(网速较低)</a></li>
                        <li><a id="btn_bt_8_0" href="#">8秒(网速较低)</a></li>
                        <li><a id="btn_bt_10_0" href="#">10秒(无所谓延迟)</a></li>
                        <li><a id="btn_bt_15_0" href="#">15秒(无所谓延迟)</a></li>
                        <li><a id="btn_bt_20_0" href="#">20秒(无所谓延迟)</a></li>
                        <li><a id="btn_bt_30_0" href="#">30秒(流畅第一)</a></li>
                    </ul>
                </div>
                <div class="btn-group dropup">
                    <button class="btn dropdown-toggle" data-toggle="dropdown">最大缓冲区<span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li><a id="btn_mbt_0_6" href="#">0.6秒(实时)</a></li>
                        <li><a id="btn_mbt_0_9" href="#">0.9秒(实时)</a></li>
                        <li><a id="btn_mbt_1_2" href="#">1.2秒(实时)</a></li>
                        <li><a id="btn_mbt_1_5" href="#">1.5秒(实时)</a></li>
                        <li><a id="btn_mbt_2_4" href="#">2.4秒(会议)</a></li>
                        <li><a id="btn_mbt_3_0" href="#">3秒(低延迟)</a></li>
                        <li><a id="btn_mbt_6_0" href="#">6秒(较低延时)</a></li>
                        <li><a id="btn_mbt_9_0" href="#">9秒(流畅播放)</a></li>
                        <li><a id="btn_mbt_12_0" href="#">12秒(流畅播放)</a></li>
                        <li><a id="btn_mbt_15_0" href="#">15秒(网速较低)</a></li>
                        <li><a id="btn_mbt_18_0" href="#">18秒(网速较低)</a></li>
                        <li><a id="btn_mbt_24_0" href="#">24秒(网速较低)</a></li>
                        <li><a id="btn_mbt_30_0" href="#">30秒(无所谓延迟)</a></li>
                        <li><a id="btn_mbt_45_0" href="#">45秒(无所谓延迟)</a></li>
                        <li><a id="btn_mbt_60_0" href="#">60秒(无所谓延迟)</a></li>
                        <li><a id="btn_mbt_90_0" href="#">90秒(流畅第一)</a></li>
                    </ul>
                </div>
                <div class="btn-group dropup">
                    <a id="btn_fullscreen" class="btn">进入全屏</a>
                </div>
                <div class="btn-group dropup">
                    <button id="btn_pause" class="btn">暂停播放</button>
                    <button id="btn_resume" class="btn hide">继续播放</button>
                </div>
                <div class="btn-group dropup">
                    <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">关闭播放器</button>
                </div>
            </div>
            <div class="hide" id="fullscreen_tips">
                请<font color="red">点击视频</font>进入全屏模式~<br/>
                由于安全原因，Flash全屏无法使用JS触发
            </div>
            <div>
                <div class="input-prepend div_play_time" title="视频的播放流畅度">
                    <span class="add-on">@F</span>
                    <input class="span2" style="width:57px" id="txt_fluency" type="text" placeholder="100%">
                </div>
                <div class="input-prepend div_play_time" title="视频总共卡顿次数">
                    <span class="add-on">@E</span>
                    <input class="span2" style="width:85px" id="txt_empty_count" type="text" placeholder="0">
                </div>
                <div class="input-prepend div_play_time" title="视频当前的帧率FPS">
                    <span class="add-on">@F</span>
                    <input class="span2" style="width:85px" id="txt_fps" type="text" placeholder="fps">
                </div>
                <div class="input-prepend div_play_time" title="视频当前的码率(视频+音频)，单位：Kbps">
                    <span class="add-on">@B</span>
                    <input class="span2" style="width:85px" id="txt_bitrate" type="text" placeholder="kbps">
                </div>
                <div class="input-prepend div_play_time" title="播放时长，格式：天 时:分:秒">
                    <span class="add-on">@T</span>
                    <input class="span2" style="width:85px" id="txt_time" type="text" placeholder="天 时:分:秒">
                </div>
            </div>
            <div style="margin-top:-12px;">
                URL: <a href="#" id="player_url"></a>
                <div class="input-prepend div_play_time" title="当前时间：年-月-日 时:分:秒">
                    <span class="add-on">@N</span>
                    <input class="span2" style="width:135px" id="player_clock" type="text" placeholder="年-月-日 时:分:秒">
                </div>
            </div>
        </div>
    </div>
    <footer>
        <p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2013</a></p>
    </footer>
</div>
</body>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/srs.page.js"></script>
<script type="text/javascript" src="js/srs.log.js"></script>
<script type="text/javascript" src="js/srs.player.js"></script>
<script type="text/javascript" src="js/srs.publisher.js"></script>
<script type="text/javascript" src="js/srs.utility.js"></script>
<script type="text/javascript" src="js/winlin.utility.js"></script>
<script type="text/javascript">
    var srs_player = null;
    var url = null;

    var __active_dar = null;
    function select_dar(dar_id, num, den) {
        srs_player.set_dar(num, den);

        if (__active_dar) {
            __active_dar.removeClass("active");
        }

        __active_dar = $(dar_id).parent();
        __active_dar.addClass("active");
    }

    var __active_size = null;
    function select_fs_size(size_id, refer, percent) {
        srs_player.set_fs(refer, percent);

        if (__active_size) {
            __active_size.removeClass("active");
        }

        __active_size = $(size_id).parent();
        __active_size.addClass("active");
    }

    var __active_bt = null;
    function select_buffer_time(bt_id, buffer_time) {
        srs_player.set_bt(buffer_time);

        if (__active_bt) {
            __active_bt.removeClass("active");
        }

        __active_bt = $(bt_id).parent();
        __active_bt.addClass("active");
    }

    $(function(){
        var query = parse_query_string();

        // get the vhost and port to set the default url.
        // for example: http://192.168.1.213/players/jwplayer6.html?port=1935&vhost=demo
        // url set to: rtmp://demo:1935/live/livestream
        srs_init_rtmp("#txt_url", "#main_modal");

        // consts for buffer and max buffer.
        var bts =  [0.1, 0.2, 0.3, 0.5, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 30];
        var mbts = [0.6, 0.9, 1.2, 1.5, 2.4, 3, 6, 9, 12, 15, 18, 24, 30, 45, 60, 90];

        // the play startup time.
        var pst = new Date();

        $("#main_modal").on("show", function(){
            if (srs_player) {
                return;
            }

            $("#div_container").remove();

            var div_container = $("<div/>");
            $(div_container).attr("id", "div_container");
            $("#player").append(div_container);

            var player = $("<div/>");
            $(player).attr("id", "player_id");
            $(div_container).append(player);

            srs_player = new SrsPlayer("player_id", srs_get_player_width(), srs_get_player_height());
            srs_player.on_player_ready = function() {
                var buffer_time = 0.5;
                if (url.indexOf('.m3u8') > 0) {
                    buffer_time = 2;
                }

                if (query.buffer) {
                    for (var i = 0; i < bts.length - 1; i++) {
                        var cur = bts[i];
                        var next = bts[i+1];
                        if (Number(query.buffer) >= cur && Number(query.buffer) < next) {
                            buffer_time = cur;
                            break;
                        }
                    }
                }

                select_buffer(buffer_time);
                this.play(url);
            };
            srs_player.on_player_metadata = function(metadata) {
                $("#btn_dar_original").text("视频原始比例" + "(" + metadata.width + ":" + metadata.height + ")");
                select_dar("#btn_dar_original", 0, 0);
                select_fs_size("#btn_fs_size_screen_100", "screen", 100);
            };
            srs_player.on_player_timer = function(time, buffer_length, kbps, fps, rtime) {
                var buffer = buffer_length / this.buffer_time * 100;
                $("#pb_buffer").width(Number(buffer).toFixed(1) + "%");

                $("#pb_buffer_bg").attr("title",
                        "缓冲区长度:" + Number(buffer_length).toFixed(1) + "秒("
                        + Number(buffer).toFixed(1) + "%)");

                $("#txt_bitrate").val(kbps.toFixed(1) + "kbps");
                $("#txt_fps").val(fps.toFixed(1) + "fps");
                $("#txt_empty_count").val(srs_player.empty_count() + "次卡顿");
                $("#txt_fluency").val(srs_player.fluency().toFixed(2) + "%");

                var time_str = "";
                // day
                time_str = padding(parseInt(time / 24 / 3600), 2, '0') + " ";
                // hour
                time = time % (24 * 3600);
                time_str += padding(parseInt(time / 3600), 2, '0') + ":";
                // minute
                time = time % (3600);
                time_str += padding(parseInt(time / 60), 2, '0') + ":";
                // seconds
                time = time % (60);
                time_str += padding(parseInt(time), 2, '0');
                // show
                $("#txt_time").val(time_str);

                var clock = new Date().getTime() / 1000;
                $("#player_clock").val(absolute_seconds_to_YYYYmmdd(clock) + " " + absolute_seconds_to_HHMMSS(clock));
            };
            srs_player.start();
        });

        $("#main_modal").on("hide", function(){
            if (srs_player) {
                srs_player.stop();
                srs_player = null;
            }
        });

        var apply_url_change = function() {
            var rtmp = parse_rtmp_url($("#txt_url").val());
            var url = "http://" + query.host + query.pathname + "?"
                    + "vhost=" + rtmp.vhost + "&app=" + rtmp.app + "&stream=" + rtmp.stream
                    + "&server=" + rtmp.server + "&port=" + rtmp.port
                    + "&autostart=true";
            $("#player_url").text($("#txt_url").val()).attr("href", url);

            $("#link_server").text(rtmp.server);
            $("#link_port").text(rtmp.port);
            $("#link_vhost").text(rtmp.vhost);
            $("#link_app").text(rtmp.app);
            $("#link_stream").text(rtmp.stream);
            $("#link_rtmp").text($("#txt_url").val());
            $("#link_url").attr("href", url);
        };

        $("#txt_url").change(function(){
            apply_url_change();
        });

        $("#btn_generate_link").click(function(){
            $("#link_modal").modal({show:true, keyboard:true});
        });

        $("#btn_play").click(function(){
            url = $("#txt_url").val();
            $("#main_modal").modal({show:true, keyboard:true});
        });

        $("#btn_fullscreen").click(function(){
            $("#fullscreen_tips").toggle();
        });

        $("#btn_pause").click(function() {
            $("#btn_resume").toggle();
            $("#btn_pause").toggle();
            srs_player.pause();
        });
        $("#btn_resume").click(function(){
            $("#btn_resume").toggle();
            $("#btn_pause").toggle();
            srs_player.resume();
        });

        if (true) {
            $("#srs_publish").click(function () {
                url = $("#srs_publish").text();
                $("#main_modal").modal({show: true, keyboard: false});
            });
            $("#srs_publish_ld").click(function () {
                url = $("#srs_publish_ld").text();
                $("#main_modal").modal({show: true, keyboard: false});
            });
            $("#srs_publish_sd").click(function () {
                url = $("#srs_publish_sd").text();
                $("#main_modal").modal({show: true, keyboard: false});
            });
            $("#srs_publish_fw").click(function () {
                url = $("#srs_publish_fw").text();
                $("#main_modal").modal({show: true, keyboard: false});
            });
            $("#srs_publish_fw_ld").click(function () {
                url = $("#srs_publish_fw_ld").text();
                $("#main_modal").modal({show: true, keyboard: false});
            });
            $("#srs_publish_fw_sd").click(function () {
                url = $("#srs_publish_fw_sd").text();
                $("#main_modal").modal({show: true, keyboard: false});
            });
        }

        var jwplayer_url = "http://" + query.host + query.dir + "/jwplayer6.html?vhost=demo.srs.com&app=live&hls_autostart=true";
        if (true) {
            $("#srs_publish_hls").attr("href", jwplayer_url + "&stream=livestream");
            $("#srs_publish_ld_hls").attr("href", jwplayer_url + "&stream=livestream_ld");
            $("#srs_publish_sd_hls").attr("href", jwplayer_url + "&stream=livestream_sd");
            var jwplayer_url = "http://" + query.host + query.dir + "/jwplayer6.html?vhost=demo.srs.com&app=forward/live&hls_autostart=true";
            $("#srs_publish_fw_hls").attr("href", jwplayer_url + "&stream=livestream");
            $("#srs_publish_fw_ld_hls").attr("href", jwplayer_url + "&stream=livestream_ld");
            $("#srs_publish_fw_sd_hls").attr("href", jwplayer_url + "&stream=livestream_sd");
        }

        if (true) {
            $("#btn_dar_original").click(function(){
                select_dar("#btn_dar_original", 0, 0);
            });
            $("#btn_dar_21_9").click(function(){
                select_dar("#btn_dar_21_9", 21, 9);
            });
            $("#btn_dar_16_9").click(function(){
                select_dar("#btn_dar_16_9", 16, 9);
            });
            $("#btn_dar_4_3").click(function(){
                select_dar("#btn_dar_4_3", 4, 3);
            });
            $("#btn_dar_fill").click(function(){
                select_dar("#btn_dar_fill", -1, -1);
            });
        }

        if (true) {
            $("#btn_fs_size_video_100").click(function(){
                select_fs_size("#btn_fs_size_video_100", "video", 100);
            });
            $("#btn_fs_size_video_75").click(function(){
                select_fs_size("#btn_fs_size_video_75", "video", 75);
            });
            $("#btn_fs_size_video_50").click(function(){
                select_fs_size("#btn_fs_size_video_50", "video", 50);
            });
            $("#btn_fs_size_screen_100").click(function(){
                select_fs_size("#btn_fs_size_screen_100", "screen", 100);
            });
            $("#btn_fs_size_screen_75").click(function(){
                select_fs_size("#btn_fs_size_screen_75", "screen", 75);
            });
            $("#btn_fs_size_screen_50").click(function(){
                select_fs_size("#btn_fs_size_screen_50", "screen", 50);
            });
        }

        if (true) {
            $("#btn_bt_0_1").click(function(){
                select_buffer_time("#btn_bt_0_1", 0.1);
            });
            $("#btn_bt_0_2").click(function(){
                select_buffer_time("#btn_bt_0_2", 0.2);
            });
            $("#btn_bt_0_3").click(function(){
                select_buffer_time("#btn_bt_0_3", 0.3);
            });
            $("#btn_bt_0_5").click(function(){
                select_buffer_time("#btn_bt_0_5", 0.5);
            });
            $("#btn_bt_0_8").click(function(){
                select_buffer_time("#btn_bt_0_8", 0.8);
            });
            $("#btn_bt_1").click(function(){
                select_buffer_time("#btn_bt_1", 1);
            });
            $("#btn_bt_2").click(function(){
                select_buffer_time("#btn_bt_2", 2);
            });
            $("#btn_bt_3").click(function(){
                select_buffer_time("#btn_bt_3", 3);
            });
            $("#btn_bt_5").click(function(){
                select_buffer_time("#btn_bt_5", 5);
            });
            $("#btn_bt_10").click(function(){
                select_buffer_time("#btn_bt_10", 10);
            });
            $("#btn_bt_30").click(function(){
                select_buffer_time("#btn_bt_30", 30);
            });
        }

        var query = parse_query_string();
        if (query.autostart == "true") {
            url = $("#txt_url").val();
            $("#main_modal").modal({show:true, keyboard:false});
        }

        apply_url_change();
    });
</script>
</html>
